package com.scau.action;

import java.util.List;

import net.sf.json.JSONArray;

import com.scau.dao.IPaymentDao;
import com.scau.service.IPaymentService;
import com.scau.vo.Payment;

/**
 * @author Jinglun
 * @create 2017年4月22日
 */
public class PaymentAction extends SuperAction {
	private String result;// 属性result，用于异步传输数据交互
	
	private Payment payment;
	private IPaymentService paymentService;
	
	public String savePayment(){
		Payment pay = getPayment();
				
		//paymentService.savePayment(pay);
		//return NONE;
		if(paymentService.savePayment(pay)){
			List<Payment> payList = paymentService.listPayment();
			JSONArray jsonArray = JSONArray.fromObject(payList.toString());
			result = jsonArray.toString();
			System.out.println("4564578888");
			return "success";
		} else {
			System.out.println("保存payment出现错误");
			return "error";
		}
	}
	
	public String listPayment(){
		List<Payment> paymentList = paymentService.listPayment();
		JSONArray jsonArray = JSONArray.fromObject(paymentList.toString());
		result = jsonArray.toString();
		return "success";
	}
	
	
	
	// get,set methods
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}
	
	public Payment getPayment() {
		return payment;
	}
	public void setPayment(Payment payment) {
		this.payment = payment;
	}
	public IPaymentService getPaymentService() {
		return paymentService;
	}
	public void setPaymentService(IPaymentService paymentService) {
		this.paymentService = paymentService;
	}

}
